package com.controller;

import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.common.ajax.AjaxRes;
import com.controller.base.BaseController;
import com.entity.Student;
import com.service.StudentService;

@Controller
@RequestMapping("/student/manager")
public class StudentController extends BaseController<Student>{
	@Autowired
	private StudentService studentService;
	
	@RequestMapping("/findStudent")
	public String findStudent(Model m){
		//ModelAndView mv = new ModelAndView();
		Student student = new Student();
		List<Student> studentList = studentService.find(student);
		m.addAttribute("student",studentList.get(0));
		return "pulicpage/Student";
	}
	
	@RequestMapping("/add")
	@ResponseBody
	public AjaxRes add(Student student){
		AjaxRes res = new AjaxRes();
		//String name = (String)getRequest().getParameter("name"));
		System.out.println("-------------"+student.getName());
		studentService.insert(student);
		res.setResMsg("成功");
		return res;
	}
}
